<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>HuiCMF Webman 2.0</title>
    <link rel="stylesheet" href="__LIB__/pear/css/pear.css"/>
    <link rel="stylesheet" href="__STATIC_ADMIN__/css/admin.css?v={$version}"/>
    <link rel="stylesheet" href="__STATIC_ADMIN__/css/admin.dark.css?v={$version}"/>
    <link rel="stylesheet" href="__STATIC_ADMIN__/css/variables.css"/>
    <link rel="stylesheet" href="__STATIC_ADMIN__/css/reset.css?v={$version}"/>
    <link rel="stylesheet" href="__STATIC_ADMIN__/css/hui-admin.css?v={$version}"/>
    <link id="layui-theme-dark-css" rel="stylesheet">
    <link id="xm-select-dark-css" rel="stylesheet">
    <script>
      var GV = {
        'site': {
          "upload_image_ext": "{php}echo get_config('upload_types_image');{/php}",
          "upload_file_ext": "{php}echo get_config('upload_types_file');{/php}",
          "chunksize": "{php}echo config('server')['max_package_size'];{/php}",
        },
        'upload_url': "/app/admin/upload/upload",
      }
    </script>
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
    <!-- 顶 部 样 式 -->
    <div class="layui-header">
        <!-- 菜 单 顶 部 -->
        <div class="layui-logo">
            <!-- 图 标 -->
            <img class="logo">
            <!-- 标 题 -->
            <span class="title"></span>
        </div>
        <!-- 顶 部 左 侧 功 能 -->
        <ul class="layui-nav layui-layout-left">
            <li class="collapse layui-nav-item">
                <a href="#" class="layui-icon layui-icon-shrink-right"></a>
            </li>
            <li class="refresh layui-nav-item">
                <a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a>
            </li>
        </ul>
        <!-- 多 系 统 菜 单 -->
        <div id="control" class="layui-layout-control"></div>
        <!-- 顶 部 右 侧 菜 单 -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide-xs">
                <a href="#" class="menuSearch layui-icon layui-icon-search"></a>
            </li>
            <li class="layui-nav-item layui-hide-xs message"></li>
            <li class="layui-nav-item layui-hide-xs">
                <a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a>
            </li>
            <li class="layui-nav-item layui-hide-xs">
                <a href="javascript:;" title="清除缓存" onclick="clearCache()">
                    <i class="layui-icon layui-icon-fonts-clear"></i>
                </a>
            </li>
            <li class="layui-nav-item layui-hide-xs">
                <a href="/" class="layui-icon layui-icon-website" target="_blank" title="首页"></a>
            </li>
            <li class="layui-nav-item user">
                <!-- 头 像 -->
                <a class="layui-icon layui-icon-username" href="javascript:;"></a>
                <!-- 功 能 菜 单 -->
                <dl class="layui-nav-child">
                    <dd>
                        <a data-open="/app/admin/account/index"
                           data-title="基本资料" data-width="550">基本资料</a>
                        <a data-open="/app/admin/account/editPwd" data-title="修改密码" data-width="550">
                            修改密码
                        </a>
                    </dd>
                    <dd>
                        <a href="javascript:void(0);" class="logout">注销登录</a>
                    </dd>
                </dl>
            </li>
            <!-- 主 题 配 置 -->
            <li class="layui-nav-item setting">
                <a href="#" class="layui-icon layui-icon-more-vertical"></a>
            </li>
        </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">
        <!-- 菜 单 顶 部 -->
        <div class="layui-logo">
            <!-- 图 标 -->
            <img class="logo">
            <!-- 标 题 -->
            <span class="title"></span>
        </div>
        <!-- 菜 单 内 容 -->
        <div class="layui-side-scroll">
            <div id="sideMenu"></div>
        </div>
    </div>
    <!-- 视 图 页 面 -->
    <div class="layui-body">
        <!-- 内 容 页 面 -->
        <div id="content" style="padding-top:10px;"></div>
    </div>
    <!--首页右下角登录成功提示框-->
    <div class="login-success-tips-rb" style="display: none">
        <div class="login-success-box">
            <p>当前登录信息：</p>
            <table class="layui-table">
                <tr>
                    <td class="login-success-box-td">IP</td>
                    <td class="session-login-ip"></td>
                </tr>
                <tr>
                    <td class="login-success-box-td">归属地</td>
                    <td class="session-login-address"></td>
                </tr>
            </table>
            <p>上次登录信息：</p>
            <table class="layui-table">
                <tr>
                    <td class="login-success-box-td">IP</td>
                    <td class="session-last-login-ip"></td>
                </tr>
                <tr>
                    <td class="login-success-box-td">归属地</td>
                    <td class="session-last-login-address"></td>
                </tr>
                <tr>
                    <td class="login-success-box-td">时间</td>
                    <td class="session-last-login-time"></td>
                </tr>
            </table>
        </div>

    </div>
    <!--end-->
    <!-- 页脚 -->
    <div class="layui-footer layui-text">
        <span class="left">Released under the Apache License 2.0.</span>
        <span class="center" id="online_status"></span>
        <span class="right">
					Copyright © 2021-<?php echo date('Y'); ?> huicmf
				</span>
    </div>
    <!-- 遮 盖 层 -->
    <div class="pear-cover"></div>
    <!-- 加 载 动 画 -->
    <div class="loader-wrapper">
        <!-- 动 画 对 象 -->
        <div class="loader"></div>
    </div>
</div>
<!-- 移 动 端 便 捷 操 作 -->
<div class="pear-collapsed-pe collapse">
    <a href="#" class="layui-icon layui-icon-shrink-right"></a>
</div>
<!-- 依 赖 脚 本 -->
<script src="__LIB__/layui/layui.js"></script>
<script src="__LIB__/pear/pear.js"></script>
<script src="__STATIC_ADMIN__/js/permission.js?v=0.0.1"></script>
<script src="__STATIC_ADMIN__/js/hui-admin.js?v={$version}"></script>
<!-- 框 架 初 始 化 -->
<script>
  // Admin
  window.Admin = {
    Account: {}
  };
  layui.use(['admin', 'jquery'], function () {
    var $ = layui.jquery;
    var admin = layui.admin;
    var layer = layui.layer;
    // yml | json | api
    admin.setConfigurationPath("__LIB__/config/pear.config.yml");

    // 渲染
    admin.render();

    //获取admin-info信息
    $.ajax({
      url: "/app/admin/account/info",
      dataType: 'json',
      success: function (res) {
        lastLoginBox(res.data.is_first_login);
        $('.session-login-ip').text(res.data.login_ip);
        $('.session-login-address').text(res.data.login_address);
        $('.session-last-login-ip').text(res.data.last_login_ip);
        $('.session-last-login-address').text(res.data.last_login_address);
        $('.session-last-login-time').text(res.data.last_login_time);
        window.Admin.Account = res.data;
      }
    });

    function lastLoginBox(isFirstLogin) {
      /*首页右下角登录成功提示框*/
      if (localStorage.getItem('session-login-success-box') == null && !isMobile() && !isFirstLogin) {
        layer.open({
          type: 1,
          title: ['<i class="layui-icon layui-icon-ok-circle" style="font-size:25px; color:#67c23a"></i>&nbsp;登录成功', 'font-size:22px;color:#555;font-weight:bold;'],
          shade: false, // 不显示遮罩
          area: ['340px', '340px'],
          content: $('.login-success-tips-rb'),
          offset: 'rb',
          time: 10000,
          success: function () {
            localStorage.setItem("session-login-success-box", true);
          }
        });
      }
    }


    window.clearCache = function () {
      $.ajax({
        url: "/app/admin/account/clearCache",
        dataType: 'json',
        success: function (res) {
          if (res.code !== 200) {
            return hui_toast('error', res.msg);
          }
          return hui_toast('success', res.msg);
        }
      });
    }

    // 注销
    admin.logout(function () {
      layer.confirm('您确定要注销吗？', {
        btn: ['确定', '取消']
      }, function () {
        $.ajax({
          url: "/app/admin/account/logout",
          dataType: "json",
          success: function (res) {
            if (res.code === 0) {
              return hui_toast('error', res.msg);
            }
            localStorage.removeItem('session-login-success-box');
            return hui_toast('success', "注销成功", function () {
              window.top.location.href = '/app/admin';
              window.top.location.reload();
            });
          }
        });
      });
      // 清空 tabs 缓存
      return new Promise((resolve) => {
        resolve(true)
      });
    });

  })
</script>
</body>
</html>
